
App<IAppOption>({
  globalData: {
    navBarHeight: 0 // 导航栏高度
  },
  onLaunch() {
    wx.$toast = this.$toast
    wx.$modal = this.$modal
    wx.getSystemInfoAsync({
      success: (res) => {
        const { platform, statusBarHeight } = res
        if (platform === 'android') {
          this.globalData.navBarHeight = statusBarHeight + 48 + 'px'
        } else {
          this.globalData.navBarHeight = statusBarHeight + 44 + 'px'
        }
      }
    })
  },
  $toast(title) {
    wx.showToast({ title, icon: 'none' })
  },
  $modal(content, title) {
    return new Promise((resolve, reject) => {
      wx.showModal({
        title: title ?? '提示',
        content,
        success(res) {
          if (res.confirm) {
            resolve()
          } else if (res.cancel) {
            reject()
          }
        }
      })
    })
  }
})
